﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNet.Highcharts.Options;
using DotNet.Highcharts.Helpers;
using DotNet.Highcharts.Enums;
using DotNet.Highcharts;
using System.Drawing;
using Point = DotNet.Highcharts.Options.Point;
using FineUI;
using FTchina.Library;
using FTchina.Logic;


public partial class ui_ESS_Default : BasePage
{
    string Dpt = string.Empty;
    string IsDYAdmin = string.Empty;

    string[] Months = new string[] { "201201", "201202", "201203", "201204", "201205", "201206", "201207", "201208", "201209", "201210", "201211","201212","201301" };
    protected void Page_Load(object sender, EventArgs e)
    {
        IsDYAdmin = RequestHelper.GetRequst("IsDYAdmin");

        // Dpt = MasterHelper.ParentItemName;  
        if (!IsPostBack)
        {

            this.ckl.DataSource = Months;
            ckl.DataBind();
            ckl.SelectedValueArray = Months;

            if (IsDYAdmin.Length > 0)
            {//如果是从大领导专用入口进来的，那么就只显示东营市分公司
                ddlDpt.Items.Add(new FineUI.ListItem("东营市分公司", "东营市分公司"));
                ddlDpt.SelectedIndex = 0;
            }
            else
            {

                #region 管理员可以查看所有的分公司
                if (MasterHelper.IsAdmin || MasterHelper.UserGroupName.Contains("市分"))
                {

                    new FTchina.ESS.ESSHighchart().FillDDLwithDpt(ddlDpt);//绑定下拉列表
                }
                else
                {
                    ddlDpt.Items.Add(new FineUI.ListItem(MasterHelper.EssAreaName, MasterHelper.EssAreaName));
                    ddlDpt.SelectedIndex = 0;
                }
            }
            #endregion
        }
         
    }


    protected void btnSelectAll_Click(object sender, EventArgs e)
    {
        if (btnSelectAll.Text == "所有账期")
        {
            ckl.SelectedValueArray = Months;
            btnSelectAll.Text = "取消";
        }
        else
        {

            ckl.SelectedValueArray = new string[] { };

            btnSelectAll.Text = "所有账期";
        }
    }
    protected void Tree1_NodeCommand(object sender, FineUI.TreeCommandEventArgs e)
    {
        // Alert.Show("你点击了树节点：" + Tree1.SelectedNodeID);

        Dpt = ddlDpt.SelectedValue;
        if (ckl.SelectedValueArray.Length == 0)
        {
            AlertLogic.ShowError("请至少选择一个账期");
            return;
        }
        string month = StringHelper.Array2String(ckl.SelectedValueArray);
        string type = Server.UrlEncode(Tree1.SelectedNodeID);// 编码报表类型
        string url = "showchart.aspx?type=" + type + "&dpt={0}&month={1}";
        if (IsDYAdmin.Length > 0)
        {
            url = url + "&IsDYAdmin=yes";
        }
        PageContext.RegisterStartupScript(TabStrip1.GetRemoveTabReference("Chart_ESS" + Tree1.SelectedNodeID));

        string script = TabStrip1.GetAddTabReference("Chart_ESS" + Tree1.SelectedNodeID, string.Format(url, Server.UrlEncode( Dpt), month), ddlDpt.SelectedValue + Tree1.SelectedNodeID, true);
        PageContext.RegisterStartupScript(script);
    }

     

}

